package 字符流;

import java.io.*;

/*
* BufferedWriter(Writer out) 字符缓冲输出流对象
* BufferedReader(Reader in) 字符缓冲输入流对象
* */
public class 字符缓冲流基本使用 {

    public static void main(String[] args) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new FileReader("D:\\C3D\\Test\\1.png"));
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("D:\\C3D\\Test\\2.png"));
        char[] chars = new char[1024*8];
        while (true){
            int read = bufferedReader.read(chars);
            if (read==-1){
                break;
            }
            bufferedWriter.write(chars,0,chars.length);
            /*每次写文件之后要清空缓冲区*/
            bufferedWriter.flush();
        }
        bufferedReader.close();
        bufferedWriter.close();
    }

}